package com.ruoyi.eqmonitor.controller;

import java.util.List;

import com.ruoyi.eqmonitor.domain.OptSewagePump;
import com.ruoyi.eqmonitor.service.IOptSewagePumpRangeService;
import com.ruoyi.eqmonitor.service.IOptSewagePumpService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.Arrays;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.security.utils.SecurityUtils;

import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 污水厂与泵站明细
 * @author ruoyi
 * @date 2022-12-16
 */
@RestController
@RequestMapping("/pump")
public class OptSewagePumpController extends BaseController{

    @Autowired
    private IOptSewagePumpRangeService iOptSewagePumpRangeService;

    @Autowired
    private IOptSewagePumpService optSewagePumpService;

    /**
     * 查询污水厂与泵站明细分页
     */
    @ApiOperation("查询污水厂与泵站明细分页")
    @GetMapping("/page")
    public TableDataInfo<?> page(OptSewagePump optSewagePump){
        startPage();
        List<OptSewagePump> list = optSewagePumpService.selectOptSewagePumpList(optSewagePump);
        return getDataTable(list);
    }

    /**
     * 查询污水厂与泵站明细列表
     */
    @ApiOperation("查询污水厂与泵站明细列表")
    @GetMapping("/list")
    public AjaxResult list(OptSewagePump optSewagePump){
        List<OptSewagePump> list = optSewagePumpService.selectOptSewagePumpList(optSewagePump);
        return success(list);
    }

    /**
     * 所有污水厂与泵站数据
     */
    @ApiOperation("所有污水厂与泵站数据")
    @GetMapping("/all")
    public AjaxResult getAll(){
        return success(optSewagePumpService.getAll());
    }

    /**
     * 根据id查询污水厂与泵站明细
     */
    @ApiOperation("根据id查询污水厂与泵站明细")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return AjaxResult.success(optSewagePumpService.selectOptSewagePumpById(id));
    }

    /**
     * 新增污水厂与泵站明细
     */
    @ApiOperation("新增污水厂与泵站明细")
    @Log(title = "污水厂与泵站明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OptSewagePump optSewagePump){
        return toAjax(optSewagePumpService.save(optSewagePump));
    }

    /**
     * 修改污水厂与泵站明细
     */
    @ApiOperation("修改污水厂与泵站明细")
    @PutMapping
    public AjaxResult edit(@RequestBody OptSewagePump optSewagePump){
        return toAjax(optSewagePumpService.updateById(optSewagePump));
    }

    /**
     * 删除污水厂与泵站明细
     */
    @ApiOperation("删除污水厂与泵站明细")
    @Log(title = "污水厂与泵站明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(optSewagePumpService.removeByIds(Arrays.asList(ids)));
    }

    /**
     * 导出污水厂与泵站明细列表
     */
    @ApiOperation("导出污水厂与泵站明细列表")
    @Log(title = "污水厂与泵站明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OptSewagePump optSewagePump){
        List<OptSewagePump> list = optSewagePumpService.selectOptSewagePumpList(optSewagePump);
        ExcelUtil<OptSewagePump> util = new ExcelUtil<OptSewagePump>(OptSewagePump.class);
        util.exportExcel(response, list, "污水厂与泵站明细数据");
    }

    /**
     * 获取污水厂, 泵站 和泵站所有设备
     */
    @ApiOperation("获取污水厂, 泵站 和泵站所有设备")
    @GetMapping("/getSewagePumpAndDevice")
    public AjaxResult getSewagePumpAndDevice(){
        return success(optSewagePumpService.getSewagePumpAndDevice());
    }

    /**
     * 获取污水厂, 泵站 服务范围
     */
    @ApiOperation("获取污水厂, 泵站 服务范围")
    @GetMapping("/getSewagePumpRangeList")
    public AjaxResult getSewagePumpRangeList(){
        return success(iOptSewagePumpRangeService.list());
    }
}
